<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <iframe src="http://localhost:3001/index.html" frameborder="0" id="frame" ></iframe>
    <script type="text/javascript">
        function load() {
            let frame = document.querySelector('#frame');
            console.log(frame);
            frame.contentWindow.postMessage('我叫俞华', 'http://localhost:3001')//向端口为4000的域发送内容"我叫俞华"
        }
        window.onmessage = function (e) {
            console.log(e.data)
        }
        load()
    </script>
</body>
</html>